package com.stu.reflection.handle_pojo;

import java.util.Date;
// 测试类
public class Main {
	public static void main(String[] args) {
		String value = "id:123|name:Bob|salary:1200.23|date:1997-11-11|company.id:111|company.name:BBB";
		Person p = ClassInstanceFactory.createInstance(Person.class, value);
		System.out.println(p);
	}
}

//POJO：
class Company{
	private int id;
	private String name;
	//getter、setter、toString
  public int getId() {
    return id;
  }
  public void setId(int id) {
    this.id = id;
  }
  public String getName() {
    return name;
  }
  public void setName(String name) {
    this.name = name;
  }
  @Override
  public String toString() {
    return "Company [id=" + id + ", name=" + name + "]";
  }
}
class Person{
	private int id;
	private String name;
	private double salary;
	private Date date;
	private Company company;
	//getter、setter、toString
  public int getId() {
    return id;
  }
  public void setId(int id) {
    this.id = id;
  }
  public String getName() {
    return name;
  }
  public void setName(String name) {
    this.name = name;
  }
  public double getSalary() {
    return salary;
  }
  public void setSalary(double salary) {
    this.salary = salary;
  }
  public Date getDate() {
    return date;
  }
  public void setDate(Date date) {
    this.date = date;
  }
  public Company getCompany() {
    return company;
  }
  public void setCompany(Company company) {
    this.company = company;
  }
  @Override
  public String toString() {
    return "Person [company=" + company + ", date=" + date + ", id=" + id + ", name=" + name + ", salary=" + salary
        + "]";
  }
}